package com.zzzy.doc.controller.mydoc;


import com.zzzy.common.vo.AjaxResult;
import com.zzzy.doc.service.mydoc.MyDocLeaderSignService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@Tag(name = "我的公文-领导签发", description = "doc113")
@Validated
@RestController
@RequestMapping("/doc/my")
public class MyDocLeaderSignController {

    @Resource
    private MyDocLeaderSignService myDocLeaderSignService;

    @PutMapping("/applyLeaderSign")
    @Operation(summary = "申请领导签发")
    @Parameter(name = "id", description = "公文ID", required = true)
    @Parameter(name = "userId", description = "用户ID", required = true)
    @PreAuthorize("@pvs.hasPermission('doc:my:update')")
    public AjaxResult applyLeaderSign(@NotNull(message = "公文ID不能为空") Long id, @NotNull(message = "用户ID不能为空") Long userId) {
        myDocLeaderSignService.applyLeaderSign(id, userId);
        return AjaxResult.success();
    }

    @PutMapping("/leaderSignComplete/{id}")
    @Operation(summary = "领导签发完毕进入清稿套红")
    @Parameter(name = "id", description = "公文ID", required = true)
    @PreAuthorize("@pvs.hasPermission('doc:my:update')")
    public AjaxResult leaderSignComplete(@NotNull(message = "公文ID不能为空") @PathVariable("id") Long id) {
        myDocLeaderSignService.leaderSignComplete(id);
        return AjaxResult.success();
    }

}
